home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util4 / cabomsrc.lha / CaBoom / CaBoom.c next >
C/C++ Source or Header  |  1995-08-24  |  17KB  |  676 lines

  1. /*
  2.  * CaBoom, 1995 Lee Kindness.
  3.  *
  4.  * Patches:
  5.  *  intuition.library OpenWindow()
  6.  *  intuition.library OpenWindowTagList()
  7.  *  intuition.library CloseWindow()
  8.  *
  9.  * When windows open or close a small 'explosion' is done.
  10.  *
  11.  * This source is in the public domain, do with it as you wish...
  12.  *
  13.  * version 1.3
  14.  *
  15.  ***************************************************************************/
  16.  
  17. #include "gst.c"
  18.  
  19.  
  20. /********************************* download dev/c/SFPatch.lha for documentation */
  21.  
  22. #include "SFPatch.h"
  23.  
  24.  
  25. /********************************* DONT auto open... */
  26.  
  27. extern struct IntuitionBase *IntuitionBase = NULL;
  28. extern struct Library *CxBase = NULL;
  29. extern struct Library *IconBase = NULL;
  30. extern struct Library *UtilityBase = NULL;
  31. extern struct GfxBase *GfxBase = NULL;
  32. extern struct Library *LayersBase = NULL;
  33.  
  34. /* Save a bit of typing */
  35. #define REG(x) register __ ## x
  36.  
  37.  
  38. /********************************* The function offsets */
  39.  
  40. #define OW_OFFSET -204
  41. #define OWTL_OFFSET -606
  42. #define CW_OFFSET -72 
  43.  
  44.  
  45. /********************************* Default prefs */
  46.  
  47. #define DEF_NOBACKDROPS FALSE
  48. #define DEF_SPEED 10000
  49. #define DEF_LINE 0xFFFF
  50. #define DEF_NSTEPS 21
  51. #define MAXSTEPS 21
  52.  
  53.  
  54. /********************************* types */
  55.  
  56. typedef struct Window * __asm (*OW_Caller)( REG(a0) struct NewWindow *, 
  57.                                             REG(a6) struct Library *);
  58. typedef struct Window * __asm (*OWTL_Caller)( REG(a0) struct NewWindow *,
  59.                                               REG(a1) struct TagItem *,
  60.                                               REG(a6) struct Library *);
  61. typedef void __asm (*CW_Caller)( REG(a0) struct Window *,
  62.                                  REG(a6) struct Library *);
  63. struct Prefs {
  64.     LONG Speed, Line, nSteps, Pri;
  65.     BOOL NoBackdrops;
  66.   struct {
  67.     struct {
  68.       int x, y;
  69.     } topleft, botright;
  70.   } step[MAXSTEPS];
  71. };
  72.  
  73.  
  74. /********************************* Prototypes */
  75.  
  76. struct Window * __asm OW_New( REG(a0) struct NewWindow *, 
  77.                               REG(a6) struct Library *);
  78. struct Window * __asm OWTL_New( REG(a0) struct NewWindow *,
  79.                                 REG(a1) struct TagItem *,
  80.                                 REG(a6) struct Library *);
  81. void __asm CW_New( REG(a0) struct Window *,
  82.                    REG(a6) struct Library *);
  83.  
  84. BOOL OpenLibs(void);
  85. void CloseLibs(void);
  86. BOOL ShowWindow(void);
  87. void line (struct RastPort *rp, LONG x1, LONG y1, LONG x2, LONG y2);
  88. void DrawOutline(struct RastPort *rp, struct Screen *screen, LONG xi, LONG yi, LONG xf, LONG yf);
  89. void MoveOutline(struct NewWindow *nwin, struct TagItem *tags, struct Window *window, BOOL reverse);
  90.  
  91. /********************************* Global vars */
  92.  
  93. SetFunc *OW_SetFunc, *OWTL_SetFunc, *CW_SetFunc;
  94. struct Remember *grk;
  95. BOOL Active;
  96. char vertag[] = "$VER: CaBoom 1.3 "__AMIGADATE__;
  97. struct Prefs prefs = {
  98.  DEF_SPEED, DEF_LINE, DEF_NSTEPS, -1, DEF_NOBACKDROPS,
  99.  {
  100.   {    0,    0,    0,    0},    /* left, top, right, bottom */
  101.   {  135,  -22,  135,  -22 },
  102.   {  265,  -30,  265,  -30 },
  103.   {  389,  -25,  389,  -25 },
  104.   {  506,   -6,  506,   -6 },
  105.   {  615,   23,  615,   23 },
  106.   {  717,   62,  717,   62 },
  107.   {  811,  111,  811,  111 },
  108.   {  895,  168,  895,  168 },
  109.   {  971,  231,  971,  231 },
  110.   { 1036,  300, 1036,  300 },
  111.   { 1090,  373, 1090,  373 },
  112.   { 1134,  449, 1134,  449 },
  113.   { 1166,  527, 1166,  527 },
  114.   { 1186,  605, 1186,  605 },
  115.   { 1194,  683, 1194,  683 },
  116.   { 1188,  759, 1188,  759 },
  117.   { 1169,  833, 1169,  833 },
  118.   { 1135,  902, 1135,  902 },
  119.   { 1087,  966, 1087,  966 },
  120.   { 1024, 1024, 1024, 1024 }    /* 21st entry */
  121.  }
  122. };
  123. /*
  124.  *  The points above were generated using an HP-28S and a bezier curve
  125.  * plotting program. The curve was broken in 20 line segments and the
  126.  * control points were: (0, 0) ; (922, -205) ; (1587, 665) ; (1024, 1024)
  127.  */
  128.  
  129.  
  130. /***************************************************************************/
  131.  
  132. /* main */
  133. int main(int argc, char **argv)
  134. {
  135.     int ret;        
  136.     ret = RETURN_OK;
  137.     Active = TRUE;
  138.     grk = NULL;
  139.     
  140.     /* check version */
  141.     if (OpenLibs()) {
  142.         struct NewBroker nb = {
  143.             NB_VERSION,
  144.             "CaBoom",
  145.             &vertag[6],
  146.             "Window explosions",
  147.             NBU_UNIQUE | NBU_NOTIFY,
  148.             COF_SHOW_HIDE,
  149.             -1,
  150.             NULL,
  151.             0
  152.         };
  153.         CxObj *broker;
  154.         
  155.         /* Get tooltypes */
  156.         if (argc ? FALSE : TRUE) {
  157.             BPTR oldcd;
  158.             struct DiskObject *dobj;
  159.             struct WBStartup *wbs;
  160.             #define PROGNAME wbs->sm_ArgList->wa_Name
  161.             #define PDIRLOCK wbs->sm_ArgList->wa_Lock
  162.             wbs = (struct WBStartup *)argv;
  163.             /* Run from WB */
  164.             oldcd = CurrentDir(PDIRLOCK);
  165.             if (dobj = GetDiskObject(PROGNAME)) {
  166.                 STRPTR s;
  167.                 if (s = FindToolType(dobj->do_ToolTypes, "SPEED")) {
  168.                     stcd_l(s, &prefs.Speed);
  169.                 }
  170.                 if (s = FindToolType(dobj->do_ToolTypes, "LINE")) {
  171.                     stcd_l(s, &prefs.Line);
  172.                 }
  173.                 if (s = FindToolType(dobj->do_ToolTypes, "NOBACKDROPS")) {
  174.                     prefs.NoBackdrops = TRUE;
  175.                 }
  176.                 if (s = FindToolType(dobj->do_ToolTypes, "CX_PRIORITY")) {
  177.                     stcd_l(s, &prefs.Pri);
  178.                 }
  179.                 FreeDiskObject(dobj);
  180.             }
  181.             CurrentDir(oldcd);
  182.         } else {
  183.             struct RDArgs *rdargs;
  184.             #define OPT_SPEED 0
  185.             #define OPT_LINE 1
  186.             #define OPT_NOBACKDROPS 2
  187.             #define OPT_CXP 3
  188.             LONG args[4] = {0, 0, 0, 0};
  189.             #define TEMPLATE "SPEED/K/N,LINE/K/N,NOBACKDROPS/S,CX_PRIORITY/K/N"
  190.             /* Run from Shell */
  191.             if (rdargs = ReadArgs(TEMPLATE, (LONG *)&args, NULL)) {
  192.                 if (args[OPT_SPEED]) {
  193.                     prefs.Speed = *((LONG *)args[OPT_SPEED]);
  194.                 }
  195.                 if (args[OPT_LINE]) {
  196.                     prefs.Line = *((LONG *)args[OPT_LINE]);
  197.                 }
  198.                  if (args[OPT_NOBACKDROPS]) {
  199.                     prefs.NoBackdrops = TRUE;
  200.                 }
  201.                 if (args[OPT_CXP]) {
  202.                     prefs.Pri = *((LONG *)args[OPT_CXP]);
  203.                 }
  204.                 FreeArgs(rdargs);    
  205.             }
  206.         }
  207.         
  208.         if (prefs.Speed < 0)
  209.             prefs.Speed = 0;
  210.     
  211.         nb.nb_Pri = prefs.Pri;
  212.                 
  213.         if ((nb.nb_Port = CreateMsgPort()) && (broker = CxBroker(&nb, NULL))) {
  214.             
  215.             /* Alloc our SetFunc's */
  216.             if((OW_SetFunc = AllocVec(sizeof(SetFunc), MEMF_CLEAR)) &&
  217.                (OWTL_SetFunc = AllocVec(sizeof(SetFunc), MEMF_CLEAR)) &&
  218.                (CW_SetFunc = AllocVec(sizeof(SetFunc), MEMF_CLEAR))) {
  219.  
  220.                 /* init. sfs */
  221.                 OW_SetFunc->sf_Func = OW_New;
  222.                 OW_SetFunc->sf_Library = (struct Library *)IntuitionBase;
  223.                 OW_SetFunc->sf_Offset = OW_OFFSET;
  224.                 OW_SetFunc->sf_QuitMethod = SFQ_COUNT;
  225.                 OWTL_SetFunc->sf_Func = OWTL_New;
  226.                 OWTL_SetFunc->sf_Library = (struct Library *)IntuitionBase;
  227.                 OWTL_SetFunc->sf_Offset = OWTL_OFFSET;
  228.                 OWTL_SetFunc->sf_QuitMethod = SFQ_COUNT;
  229.                 CW_SetFunc->sf_Func = CW_New;
  230.                 CW_SetFunc->sf_Library = (struct Library *)IntuitionBase;
  231.                 CW_SetFunc->sf_Offset = CW_OFFSET;
  232.                 CW_SetFunc->sf_QuitMethod = SFQ_COUNT;
  233.  
  234.                 /* Replace the functions */
  235.                 if ((SFReplace(OW_SetFunc)) &&
  236.                     (SFReplace(OWTL_SetFunc)) &&
  237.                     (SFReplace(CW_SetFunc))) {
  238.                     
  239.                     ULONG sig, sret;
  240.                     BOOL finished;
  241.                     
  242.                     ActivateCxObj(broker, 1L);
  243.  
  244.                     finished = FALSE;
  245.                     sig = 1 << nb.nb_Port->mp_SigBit;
  246.                     
  247.                     do {
  248.                         sret = Wait(SIGBREAKF_CTRL_C | sig);
  249.                         if (sret & sig) {
  250.                             CxMsg *msg;
  251.                             while(msg = (CxMsg *)GetMsg(nb.nb_Port)) {
  252.                                 switch(CxMsgType(msg)) {
  253.                                     case CXM_COMMAND:
  254.                                         switch(CxMsgID(msg)) {
  255.                                             case CXCMD_DISABLE:
  256.                                                 ActivateCxObj(broker, 0L);
  257.                                                 Active = FALSE;
  258.                                                 break;
  259.                                             case CXCMD_ENABLE:
  260.                                                 ActivateCxObj(broker, 1L);
  261.                                                 Active = TRUE;
  262.                                                 break;
  263.                                             case CXCMD_KILL:
  264.                                                 finished = TRUE;
  265.                                                 break;
  266.                                             case CXCMD_UNIQUE:
  267.                                                 finished = ShowWindow();
  268.                                                 break;
  269.                                             case CXCMD_APPEAR:
  270.                                                 finished = ShowWindow();
  271.                                                 break;
  272.                                         }
  273.                                         break;
  274.                                 }
  275.                                 ReplyMsg((struct Message *)msg);
  276.                             }
  277.                         }
  278.                         if (sret & SIGBREAKF_CTRL_C)
  279.                             finished = TRUE;
  280.                     } while (!finished);
  281.                     ActivateCxObj(broker, 0L);
  282.     
  283.                     /* Restore functions */
  284.                     SFRestore(CW_SetFunc);
  285.                     SFRestore(OWTL_SetFunc);
  286.                     SFRestore(OW_SetFunc);
  287.                 }
  288.                 FreeVec(CW_SetFunc);
  289.                 FreeVec(OWTL_SetFunc);
  290.                 FreeVec(OW_SetFunc);
  291.             }
  292.             DeleteCxObj(broker);
  293.             DeletePort(nb.nb_Port);
  294.         }
  295.     }
  296.     CloseLibs();
  297.     return(ret);
  298. }
  299.  
  300.  
  301. /***************************************************************************/
  302. /* Show our window... currently only a requester */
  303. BOOL ShowWindow(void)
  304. {
  305.     struct EasyStruct ez = {
  306.         sizeof(struct EasyStruct),
  307.         0,
  308.         "CaBoom",
  309.         "%s ©Lee Kindness.\n\n"
  310.         "wangi@fido.zetnet.co.uk\n\n"
  311.         "Window explosions\n\n"
  312.         "Read \"CaBoom.guide\" for more information\n\n"
  313.         "(Program may take a couple of seconds to quit)",
  314.         "Quit|Hide"
  315.     };
  316.     return((BOOL)EasyRequest(NULL, &ez, NULL, &vertag[6]));
  317. }
  318.  
  319.  
  320. /***************************************************************************/
  321. /* Open all used libraries */
  322. BOOL OpenLibs(void)
  323. {
  324.     BOOL ret;
  325.     IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
  326.     CxBase = OpenLibrary("commodities.library", 37);
  327.     IconBase = OpenLibrary("icon.library", 37);
  328.     UtilityBase = OpenLibrary("utility.library", 37);
  329.     GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37);
  330.     LayersBase = OpenLibrary("layers.library", 37);
  331.     ret = ((IntuitionBase) && 
  332.            (CxBase) && 
  333.            (IconBase) &&
  334.            (UtilityBase) &&
  335.            (GfxBase) &&
  336.            (LayersBase));
  337.     return(ret);
  338. }
  339.  
  340.  
  341. /***************************************************************************/
  342. /* Close all libraries */
  343. void CloseLibs(void)
  344. {
  345.     if (LayersBase)
  346.         CloseLibrary(LayersBase);
  347.     if (GfxBase)
  348.         CloseLibrary((struct Library *)GfxBase);
  349.     if (UtilityBase)
  350.         CloseLibrary(UtilityBase);
  351.     if (IconBase)
  352.         CloseLibrary(IconBase);
  353.     if (CxBase)
  354.         CloseLibrary(CxBase);
  355.     if (IntuitionBase)
  356.         CloseLibrary((struct Library *)IntuitionBase);
  357. }
  358.  
  359.  
  360. /***************************************************************************/
  361. /* Draws a line */
  362. void line (struct RastPort *rp, LONG x1, LONG y1, LONG x2, LONG y2)
  363. {
  364.     Move(rp, x1, y1);
  365.     Draw(rp, x2, y2);
  366. }
  367.  
  368.  
  369. /***************************************************************************/
  370. /* Draws a box-outline */
  371.  
  372. #define MAX(a,b) (((a)>(b))?(a):(b))
  373. #define MIN(a,b) (((a)<(b))?(a):(b))
  374. #define xclip(x) (MAX(0, MIN(x, screen->Width - 1)))
  375. #define yclip(y) (MAX(0, MIN(y, screen->Height - 1)))
  376.  
  377. void DrawOutline(struct RastPort *rp, struct Screen *screen, LONG xi, LONG yi, LONG xf, LONG yf)
  378. {
  379.     xi = xclip(xi);
  380.     yi = yclip(yi);
  381.     xf = xclip(xf);
  382.     yf = yclip(yf);
  383.     line(rp, xi, yi, xf, yi);
  384.     line(rp, xf, yi, xf, yf);
  385.     line(rp, xf, yf, xi, yf);
  386.     line(rp, xi, yf, xi, yi);
  387. }
  388.  
  389.  
  390. /***************************************************************************/
  391. /* The 'anim' */
  392. void MoveOutline(struct NewWindow *nwin, struct TagItem *tags, struct Window *window, BOOL reverse)
  393. {
  394.     struct RastPort *rp;
  395.     struct timerequest *tr;
  396.     struct MsgPort *tmp;
  397.     struct Screen *screen;
  398.     LONG x, y, w, h;
  399.     BOOL unlockscr, backdrop;
  400.     struct TagItem *tag;
  401.     
  402.     if (Active)
  403.     {
  404.         unlockscr = FALSE;
  405.         /* Get Screen that window will open/close on */
  406.         if( reverse )
  407.         {
  408.             screen = window->WScreen;
  409.         } else
  410.         {
  411.             screen = NULL;
  412.             if (nwin)
  413.             {
  414.                 if ((nwin->Type != WBENCHSCREEN))
  415.                     screen = nwin->Screen;
  416.             }
  417.             if (tag = FindTagItem(WA_CustomScreen, tags))
  418.             {
  419.                 screen = (struct Screen *)tag->ti_Data;
  420.             } else
  421.             {
  422.                 if (tag = FindTagItem(WA_PubScreen, tags))
  423.                 {
  424.                     screen = (struct Screen *)tag->ti_Data;
  425.                 } else
  426.                 {
  427.                     if (tag = FindTagItem(WA_PubScreenName, tags))
  428.                     {
  429.                         screen = LockPubScreen((STRPTR)(tag->ti_Data));
  430.                         unlockscr = TRUE;
  431.                     }
  432.                 }
  433.             }
  434.         }
  435.         
  436.         if (screen == NULL)
  437.         {
  438.             screen = LockPubScreen(NULL);
  439.             unlockscr = TRUE;
  440.         }
  441.     
  442.         if (screen)
  443.         {
  444.             /* Calculate dimensions and positioning */
  445.             if( reverse )
  446.             {
  447.                 x = window->LeftEdge;
  448.                 y = window->TopEdge;
  449.                 w = window->Width;
  450.                 h = window->Height;
  451.             } else
  452.             {
  453.                 if (nwin)
  454.                 {
  455.                     x = nwin->LeftEdge;
  456.                     y = nwin->TopEdge;
  457.                     w = nwin->Width;
  458.                     h = nwin->Height;
  459.                 } else
  460.                 {
  461.                     x = 0;
  462.                     y = 0;
  463.                     w = screen->Width;
  464.                     h = screen->Height;
  465.                 }
  466.                 if (tag = FindTagItem(WA_Left, tags))
  467.                     x = tag->ti_Data;
  468.                 if (tag = FindTagItem(WA_Top, tags))
  469.                     y = tag->ti_Data;
  470.                 if (tag = FindTagItem(WA_InnerWidth, tags))
  471.                     w = tag->ti_Data + 8;
  472.                 if (tag = FindTagItem(WA_Width, tags))
  473.                     w = tag->ti_Data;
  474.                 if (tag = FindTagItem(WA_InnerHeight, tags))
  475.                     h = tag->ti_Data + 8;
  476.                 if (tag = FindTagItem(WA_Height, tags))
  477.                     h = tag->ti_Data;
  478.             }
  479.             
  480.             /* findout if backdrop */
  481.             backdrop = FALSE;
  482.             if( reverse )
  483.             {
  484.                 if( window->Flags & WFLG_BACKDROP )
  485.                     backdrop = TRUE;
  486.             } else
  487.             {
  488.                 if( (nwin) && (nwin->Flags & WFLG_BACKDROP) )
  489.                     backdrop = TRUE;
  490.                 if( (tag = FindTagItem(WA_Flags, tags)) && (tag->ti_Data & WFLG_BACKDROP) )
  491.                     backdrop = TRUE;
  492.                 if( (tag = FindTagItem(WA_Backdrop, tags)) && (tag->ti_Data) )
  493.                     backdrop = TRUE;
  494.             }
  495.             
  496.             if ( !(prefs.NoBackdrops && backdrop) )
  497.             {
  498.                 if ((rp = AllocVec(sizeof(struct RastPort), MEMF_CLEAR)) &&
  499.                 (tmp = CreateMsgPort()) &&
  500.                 (tr = (struct timerequest *)CreateIORequest(tmp, sizeof(struct timerequest))))
  501.                 {
  502.                     LONG timerres;
  503.                     register LONG i, n;
  504.                     LONG dxi, dyi, dxf, dyf;
  505.                     LONG nxi, nyi, nxf, nyf;
  506.                     LONG  xi,  yi,  xf,  yf;
  507.                     LONG x0, y0;
  508.         
  509.                     timerres = OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *)tr, 0);
  510.  
  511.                     xi = 0;
  512.                     yi = 0;
  513.                     xf = 0;
  514.                     yf = 0;
  515.     
  516.                     *rp = screen->RastPort;
  517.     
  518.                     SetDrMd(rp, COMPLEMENT | JAM1);
  519.                   SetDrPt(rp, prefs.Line);
  520.                   SetAPen(rp, 1);
  521.     
  522.                     x0 = screen->MouseX;
  523.                   y0 = screen->MouseY;
  524.  
  525.                     dxi = x - x0;
  526.                     dyi = y - y0;
  527.                     dxf = (x + w - 1) - x0;
  528.                     dyf = (y + h - 1) - y0;
  529.     
  530.                     LockLayers (&screen->LayerInfo);
  531.  
  532.                     for (i = 0; i < prefs.nSteps; i++)
  533.                     {
  534.                         if (reverse)
  535.                             n = prefs.nSteps - i;
  536.                         else
  537.                             n = i;
  538.         
  539.                         nxi = x0 + ((prefs.step[n].topleft.x * dxi) / 1024);
  540.                         nyi = y0 + ((prefs.step[n].topleft.y * dyi) / 1024);
  541.                         nxf = x0 + ((prefs.step[n].botright.x * dxf) / 1024);
  542.                         nyf = y0 + ((prefs.step[n].botright.y * dyf) / 1024);
  543.                         if (n)
  544.                             DrawOutline(rp, screen, xi, yi, xf, yf);    /* erases outline */
  545.                         xi = nxi;
  546.                         yi = nyi;
  547.                         xf = nxf;
  548.                         yf = nyf;
  549.                         DrawOutline(rp, screen, xi, yi, xf, yf);    /* draws outline */
  550.             
  551.                         if ((prefs.Speed) && (timerres == 0))
  552.                         {
  553.                             tr->tr_node.io_Command = TR_ADDREQUEST;
  554.                             tr->tr_node.io_Flags = 0;
  555.                             tr->tr_time.tv_secs = 0;
  556.                             tr->tr_time.tv_micro = prefs.Speed;
  557.                             DoIO((struct IORequest *)tr);
  558.                         }
  559.                     }
  560.                     DrawOutline(rp, screen, xi, yi, xf, yf);
  561.                     if (timerres == 0)
  562.                         CloseDevice((struct IORequest *)tr);
  563.                     DeleteIORequest((struct IORequest *)tr);
  564.                     DeleteMsgPort(tmp);
  565.                     FreeVec(rp);
  566.                 }
  567.                 UnlockLayers(&screen->LayerInfo);
  568.             }
  569.  
  570.             if (unlockscr)
  571.                 UnlockPubScreen(NULL, screen);    
  572.         }
  573.     }
  574. }
  575.  
  576. /***************************************************************************/
  577. /* The new OpenWindow() */
  578. struct Window * __saveds __asm OW_New(REG(a0) struct NewWindow *nwin, 
  579.                                       REG(a6) struct Library *lib)
  580. {
  581.     OW_Caller Caller;
  582.     struct Window *ret;
  583.     
  584.     /* increment count */
  585.     Forbid();
  586.     OW_SetFunc->sf_Count += 1;
  587.     Permit();
  588.     
  589.     MoveOutline(nwin, NULL, NULL, FALSE);
  590.     
  591.     Caller = (APTR)OW_SetFunc->sf_OriginalFunc;
  592.     
  593.     /* Pass the buck */
  594.     ret = Caller(nwin, lib);
  595.     
  596.     /* decrement count */
  597.     Forbid();
  598.     OW_SetFunc->sf_Count -= 1;
  599.     Permit();
  600.     
  601.     /* and return */
  602.     return(ret);
  603.  
  604. }
  605.  
  606.  
  607. /***************************************************************************/
  608. /* The new OpenWindowTagList() */
  609. struct Window * __saveds __asm OWTL_New(REG(a0) struct NewWindow *nwin, 
  610.                                         REG(a1) struct TagItem *tags,
  611.                                         REG(a6) struct Library *lib)
  612. {
  613.     struct Window *ret;
  614.     OWTL_Caller Caller;
  615.     
  616.     /* increment count */
  617.     Forbid();
  618.     OWTL_SetFunc->sf_Count += 1;
  619.     Permit();
  620.     
  621.     MoveOutline(nwin, tags, NULL, FALSE);
  622.     
  623.     Caller = (APTR)OWTL_SetFunc->sf_OriginalFunc;
  624.     
  625.     /* Pass the buck */
  626.     ret = Caller(nwin, tags, lib);
  627.     
  628.     /* decrement count */
  629.     Forbid();
  630.     OWTL_SetFunc->sf_Count -= 1;
  631.     Permit();
  632.     
  633.     /* and return */
  634.     return(ret);
  635. }
  636.  
  637.  
  638. /***************************************************************************/
  639. /* The new CloseWindow() */
  640. void __saveds __asm CW_New(REG(a0) struct Window *win, 
  641.                            REG(a6) struct Library *lib)
  642. {
  643.     CW_Caller Caller;
  644.     struct Window *wincopy;
  645.     
  646.     /* increment count */
  647.     Forbid();
  648.     CW_SetFunc->sf_Count += 1;
  649.     Permit();
  650.     
  651.     if( wincopy = AllocVec(sizeof(struct Window), MEMF_CLEAR) )
  652.     {
  653.         *wincopy = *win;
  654.     }
  655.  
  656.     Forbid();
  657.  
  658.     /* Pass the buck */
  659.     Caller = (APTR)CW_SetFunc->sf_OriginalFunc;
  660.     Caller(win, lib);
  661.     
  662.     if ( wincopy )
  663.     {
  664.         MoveOutline(NULL, NULL, wincopy, TRUE);
  665.         FreeVec(wincopy);
  666.     }
  667.  
  668.     Permit();
  669.     
  670.     /* decrement count */
  671.     Forbid();
  672.     CW_SetFunc->sf_Count -= 1;
  673.     Permit();
  674. }
  675. /***************************************************************************/
  676.